﻿

/* editing-backend.js */
Exhibit.EditingBackend=function(){this._nodeTree={};
this._dataTree={};
};
Exhibit.EditingBackend.prototype.rebuildNodeTree=function(D,C){if(root==undefined||root==null){root=document.body;
}var B=[];
var A=function(G,F,I){var E;
if((E=Exhibit.getAttribute(F,"ex:property"))!=null){B.properties[E]=[];
walkItem(node,E);
}else{if(F.className=="editable-exhibit-value"||F.className=="modified-exhibit_value"){B.properties[I].push(node);
}else{for(var H=0;
H<node.childNodes.length;
H++){A(node.childNodes[H],I);
}}}};
return this._nodeTree=A(D,C,null);
};
Exhibit.EditingBackend.prototype.rebuildDataTree=function(I){this._mode=(I==undefined||I==null)?"full":"diff";
var A=[];
for(var B in this._nodeTree){if(this._mode="full"){var G=I.getAllProperties();
var C=Exhibit.ViewPanel.getPropertyValuesPairs(B,G,I);
A[B]={};
for(var E=0;
E<C.length;
E++){var D=C[E];
A[B][D.propertyID]=[];
for(var F=0;
F<D.values.length;
F++){A[B][D.propertyID].push(D.values[F]);
}}}for(var J in this._nodeTree[F].properties){A[B][J]=[];
valueNodes=this._nodeTree[B].properties[J];
for(var H=0;
H<values.length;
H++){A[B][J].push(Exhibit.EditingBackend.getNodeValue(valueNodes));
}}}return this._dataTree=A;
};
Exhibit.EditingBackend.getNodeValue=function(A){if(A.tag.toLowerCase()=="input"){return A.value;
}else{return A.innerHTML;
}};


/* extra.js */
Exhibit.UI.makeEditValueSpan=function(C,G,D,F){var E=document.createElement("span");
E.className="exhibit-value";
var B=document.createElement("input");
B.className="editable-exhibit-value";
var B=document.createElement("input");
B.className="editable-exhibit-value";
B.value=C;
E.appendChild(B);
if(F){var A=Exhibit.UI.createTranslucentImage("images/remove-icon.png");
A.width=10;
A.height=10;
A.style.margin=0;
A.title="remove value";
SimileAjax.WindowManager.registerEvent(A,"click",function(I,H,J){E.parentNode.removeChild(E);
});
E.appendChild(A);
}return E;
};
Exhibit.UI.makeEditItemSpan=function(F,C,B,D){if(C==null){C=database.getObject(F,"label");
if(C==null){C=F;
}}var A=SimileAjax.DOM.createElementFromString('<a href="'+Exhibit.Persistence.getItemLink(F)+"\" class='exhibit-item'>"+C+"</a>");
var E=function(H,G,I){Exhibit.UI.showEditItemInPopup(F,H,B);
};
SimileAjax.WindowManager.registerEvent(A,"click",E,D);
return A;
};
Exhibit.UI.correctPopupBehavior=function(B,C,D,A){D.firstChild.style.display="none";
D.lastChild.onclick="";
SimileAjax.WindowManager.registerEvent(D.lastChild,"click",function(F,E,G){B._saveFromEditingLens(C,D,A);
});
};
Exhibit.UI.showEditItemInPopup=function(G,D,C){var F=SimileAjax.DOM.getPageCoordinates(D);
var B=SimileAjax.Graphics.createBubbleForPoint(F.left+Math.round(D.offsetWidth/2),F.top+Math.round(D.offsetHeight/2),C.getSetting("bubbleWidth"),C.getSetting("bubbleHeight"));
var A=document.createElement("div");
var E=C.getLensRegistry().createLens(G,A,C,true);
E._convertLens(G,A,C,true);
Exhibit.UI.correctPopupBehavior(E,G,A,C);
B.content.appendChild(A);
};
Exhibit.Database._Impl.prototype.getItem=function(A){if(this._items.contains(A)){this._items[A];
}return null;
};
Exhibit.Database._Impl.prototype.reloadItem=function(C,B){try{for(p in B){this.removeObjects(C,p);
}var D={};
D.items=[B];
database.loadData(D);
}catch(A){alert(A);
}};
Exhibit.createPopupMenu=function(A,D){var C=document.createElement("div");
C.className="exhibit-menu-popup exhibit-ui-protection";
var B={elmt:C,close:function(){try{document.body.removeChild(this.elmt);
}catch(E){}},open:function(){var F=this;
this.layer=SimileAjax.WindowManager.pushLayer(function(){F.close();
},true,this.elmt);
document.body.appendChild(C);
var G=document.body.offsetWidth;
var E=document.body.offsetHeight;
var H=SimileAjax.DOM.getPageCoordinates(A);
if(D=="center"){C.style.top=(H.top+A.scrollHeight)+"px";
C.style.left=(H.left+Math.ceil(A.offsetWidth-C.offsetWidth)/2)+"px";
}else{if(D=="right"){C.style.top=H.top+"px";
C.style.left=(H.left+C.offsetWidth)+"px";
}else{C.style.top=(H.top+A.scrollHeight)+"px";
C.style.left=H.left+"px";
}}},makeMenuItem:function(G,H,I){var F=this;
var E=document.createElement("a");
E.className="exhibit-menu-item";
E.href="javascript:";
E.onmouseover=function(){F._mouseoverMenuItem(E);
};
if(I!=null){SimileAjax.WindowManager.registerEvent(E,"click",function(L,K,M){I(L,K,M);
SimileAjax.WindowManager.popLayer(F.layer);
SimileAjax.DOM.cancelEvent(K);
return false;
});
}var J=document.createElement("div");
E.appendChild(J);
J.appendChild(SimileAjax.Graphics.createTranslucentImage(H!=null?H:(Exhibit.urlPrefix+"images/blank-16x16.png")));
J.appendChild(document.createTextNode(G));
return E;
},appendMenuItem:function(E,F,G){this.elmt.appendChild(this.makeMenuItem(E,F,G));
},makeSectionHeading:function(E){var F=document.createElement("div");
F.className="exhibit-menu-section";
F.innerHTML=E;
return F;
},appendSectionHeading:function(E,F){this.elmt.appendChild(this.makeSectionHeading(E,F));
},makeSubMenu:function(I,G){var M=this;
var J=document.createElement("a");
J.className="exhibit-menu-item potluck-submenu";
J.href="javascript:";
var K=Exhibit.createPopupMenu(J,"right");
J.onmousemove=function(){M._mousemoveSubmenu(J,K);
};
var E=document.createElement("div");
J.appendChild(E);
var L=document.createElement("table");
L.cellSpacing=0;
L.cellPadding=0;
L.width="100%";
E.appendChild(L);
var H=L.insertRow(0);
var F=H.insertCell(0);
F.appendChild(document.createTextNode(I));
F=H.insertCell(1);
F.align="right";
F.style.verticalAlign="middle";
F.appendChild(Exhibit.UI.createTranslucentImage("images/submenu.png"));
G.appendChild(J);
return K;
},appendSubMenu:function(E){return this.makeSubMenu(E,C);
},appendSeparator:function(){var E=document.createElement("hr");
this.elmt.appendChild(E);
},_mousemoveSubmenu:function(G,F){if(this._submenu!=null){if(this._submenu!=G){if(this._timer!=null){window.clearTimeout(this._timer);
this._timer=null;
}var E=this;
this._timer=window.setTimeout(function(){E._timer=null;
E._closeSubmenu();
E._openSubmenu(G,F);
},200);
}}else{this._openSubmenu(G,F);
}},_mouseoverMenuItem:function(F){var E=this;
if(this._submenu!=null&&this._timer==null){this._timer=window.setTimeout(function(){E._timer=null;
E._closeSubmenu();
},200);
}},_openSubmenu:function(F,E){this._submenu=F;
this._submenuDom=E;
E.open();
},_closeSubmenu:function(){if(this._submenuDom!=null){this._submenuDom.close();
}this._submenu=null;
this._submenuDom=null;
},_submenu:null,_submenuDom:null,_timer:null};
return B;
};
Exhibit.UI.removeChildren=function(B){for(var A=B.childNodes.length;
A>0;
A--){B.removeChild(B.lastChild);
}};
Exhibit.UI.findClassMembers=function(C,D){var B=[];
var A=function(F){if(F.className==C){B.push(F);
}else{for(var E=0;
E<F.childNodes.length;
E++){A(F.childNodes[E]);
}}};
A(D);
return B;
};
Exhibit.ViewPanel.getPropertyValuesPairs=function(F,G,E){var D=[];
var B=function(M,J){var L=E.getProperty(M);
var I=J?E.getObjects(F,M):E.getSubjects(F,M);
var K=I.size();
if(K>0){var H=L.getValueType()=="item";
var N={propertyID:M,propertyLabel:J?(K>1?L.getPluralLabel():L.getLabel()):(K>1?L.getReversePluralLabel():L.getReverseLabel()),valueType:L.getValueType(),values:[]};
if(H){I.visit(function(P){var O=E.getObject(P,"label");
N.values.push(O!=null?O:P);
});
}else{I.visit(function(O){N.values.push(O);
});
}D.push(N);
}};
for(var A=0;
A<G.length;
A++){var C=G[A];
if(typeof C=="string"){B(C,true);
}else{B(C.property,C.forward);
}}return D;
};
Exhibit.TileView.createFromDOM=function(D,C,B){var E=Exhibit.getConfigurationFromDOM(D);
var A=new Exhibit.TileView(C!=null?C:D,Exhibit.UIContext.createFromDOM(D,B));
A._orderedViewFrame.configureFromDOM(D);
A._orderedViewFrame.configure(E);
A._editSetting=Exhibit.getAttribute(D,"editing");
if(A._editSetting==null){A._editSetting=false;
}A._initializeUI();
return A;
};
Exhibit.TileView.prototype._reconstruct=function(){var A=this;
var B={div:this._dom.bodyDiv,contents:null,groupDoms:[],groupCounts:[]};
var C=function(D){for(var E=D;
E<B.groupDoms.length;
E++){B.groupDoms[E].countSpan.innerHTML=B.groupCounts[E];
}B.groupDoms=B.groupDoms.slice(0,D);
B.groupCounts=B.groupCounts.slice(0,D);
if(D>0){B.div=B.groupDoms[D-1].contentDiv;
}else{B.div=A._dom.bodyDiv;
}B.contents=null;
};
this._orderedViewFrame.onNewGroup=function(D,G,E){C(E);
var F=Exhibit.TileView.constructGroup(E,D);
B.div.appendChild(F.elmt);
B.div=F.contentDiv;
B.groupDoms.push(F);
B.groupCounts.push(0);
};
this._orderedViewFrame.onNewItem=function(H,D){if(B.contents==null){B.contents=Exhibit.TileView.constructList();
B.div.appendChild(B.contents);
}for(var E=0;
E<B.groupCounts.length;
E++){B.groupCounts[E]++;
}var G=document.createElement("li");
var F=A._uiContext.getLensRegistry().createLens(H,G,A._uiContext,A._editSetting);
B.contents.appendChild(G);
};
this._div.style.display="none";
this._dom.bodyDiv.innerHTML="";
this._orderedViewFrame.reconstruct();
C(0);
this._div.style.display="block";
};
Exhibit.ThumbnailView.createFromDOM=function(D,C,B){var E=Exhibit.getConfigurationFromDOM(D);
var A=new Exhibit.ThumbnailView(C!=null?C:D,Exhibit.UIContext.createFromDOM(D,B,true));
A._lensRegistry=Exhibit.UIContext.createLensRegistryFromDOM(D,E,B.getLensRegistry());
A._orderedViewFrame.configureFromDOM(D);
A._orderedViewFrame.configure(E);
A._editSetting=Exhibit.getAttribute(D,"editing");
if(A._editSetting==null){A._editSetting=false;
}A._initializeUI();
return A;
};
Exhibit.ThumbnailView.prototype._reconstruct=function(){var A=this;
var B={div:this._dom.bodyDiv,itemContainer:null,groupDoms:[],groupCounts:[]};
var C=function(D){for(var E=D;
E<B.groupDoms.length;
E++){B.groupDoms[E].countSpan.innerHTML=B.groupCounts[E];
}B.groupDoms=B.groupDoms.slice(0,D);
B.groupCounts=B.groupCounts.slice(0,D);
if(D>0){B.div=B.groupDoms[D-1].contentDiv;
}else{B.div=A._dom.bodyDiv;
}B.itemContainer=null;
};
this._orderedViewFrame.onNewGroup=function(D,G,E){C(E);
var F=Exhibit.ThumbnailView.constructGroup(E,D);
B.div.appendChild(F.elmt);
B.div=F.contentDiv;
B.groupDoms.push(F);
B.groupCounts.push(0);
};
this._orderedViewFrame.onNewItem=function(H,E){if(B.itemContainer==null){B.itemContainer=Exhibit.ThumbnailView.constructItemContainer();
B.div.appendChild(B.itemContainer);
}for(var F=0;
F<B.groupCounts.length;
F++){B.groupCounts[F]++;
}var D=document.createElement("div");
D.className=SimileAjax.Platform.browser.isIE?"exhibit-thumbnailView-itemContainer-IE":"exhibit-thumbnailView-itemContainer";
var G=A._lensRegistry.createLens(H,D,A._uiContext,A._editSetting);
B.itemContainer.appendChild(D);
};
this._div.style.display="none";
this._dom.bodyDiv.innerHTML="";
this._orderedViewFrame.reconstruct();
C(0);
this._div.style.display="block";
};


/* editing-formatter.js */
Exhibit.Formatter._ListFormatter.prototype.formatList=function(E,G,H,B,A){var D=this._uiContext;
var C=this;
if(G==0){if(this._emptyText!=null&&this._emptyText.length>0){B(document.createTextNode(this._emptyText));
}}else{if(G==1){E.visit(function(I){D.format(I,H,B,A);
});
}else{var F=0;
if(G==2){E.visit(function(I){D.format(I,H,B,A);
F++;
if(F==1){B(document.createTextNode(C._pairSeparator));
}});
}else{E.visit(function(I){D.format(I,H,B,A);
F++;
if(F<G){B(document.createTextNode((F==G-1)?C._lastSeparator:C._separator));
}});
}}}};
Exhibit.Formatter._TextFormatter.prototype.format=function(E,B,A){var C=this;
var D=document.createElement("span");
D.innerHTML=this.formatText(E);
if(A&&!A){D.setAttribute("ex:value",E);
D.className="editable-exhibit-value";
SimileAjax.WindowManager.registerEvent(D,"click",function(){var G=document.createElement("span");
G.setAttribute("ex:value",E);
var F=document.createElement("input");
F.style.width=D.style.width;
F.value=E;
G.className="editing-parent";
G.appendChild(F);
SimileAjax.WindowManager.registerEvent(F,"blur",function(){var H=G.parentNode;
var I=F.value;
C.format(I,function(J){J.setAttribute("ex:value",E);
J.className=I==E?"editable-exhibit-value":"modified-exhibit-value";
B(J);
},A);
H.removeChild(G);
});
D.parentNode.replaceChild(G,D);
});
}B(D);
};
Exhibit.Formatter._BooleanFormatter.prototype.format=function(D,B,A){var C=document.createElement("span");
C.innerHTML=this.formatText(D);
B(C);
};
Exhibit.Formatter._BooleanFormatter.prototype.formatText=function(A){return(typeof A=="boolean"?A:(typeof A=="string"?(A=="true"):false))?"true":"false";
};
Exhibit.Formatter._NumberFormatter.prototype.format=function(C,B,A){B(document.createTextNode(this.formatText(C)));
};
Exhibit.Formatter._NumberFormatter.prototype.formatText=function(A){if(this._decimalDigits==-1){return A.toString();
}else{return new Number(A).toFixed(this._decimalDigits);
}};
Exhibit.Formatter._ImageFormatter.prototype.format=function(D,B,A){var C=document.createElement("img");
C.src=D;
if(this._tooltip!=null){if(typeof this._tooltip=="string"){C.title=this._tootlip;
}else{C.title=this._tooltip.evaluateSingleOnItem(this._uiContext.getSetting("itemID"),this._uiContext.getDatabase()).value;
}}B(C);
};
Exhibit.Formatter._ImageFormatter.prototype.formatText=function(A){return A;
};
Exhibit.Formatter._URLFormatter.prototype.format=function(D,C,B){var A=document.createElement("a");
A.href=D;
A.innerHTML=D;
if(this._target!=null){A.target=this._target;
}if(this._externalIcon!=null){}C(A);
};
Exhibit.Formatter._URLFormatter.prototype.formatText=function(A){return A;
};
Exhibit.Formatter._CurrencyFormatter.prototype.format=function(D,B,A){var E=this.formatText(D);
if(D<0&&this._negativeFormat.red){var C=document.createElement("span");
C.innerHTML=E;
C.style.color="red";
B(C);
}else{B(document.createTextNode(E));
}};
Exhibit.Formatter._CurrencyFormatter.prototype.formatText=function(C){var B=C<0;
var D;
if(this._decimalDigits==-1){D=Math.abs(C);
}else{D=new Number(Math.abs(C)).toFixed(this._decimalDigits);
}var A=(B&&this._negativeFormat.signed)?"-":"";
if(B&&this._negativeFormat.parentheses){D="("+D+")";
}switch(this._negativeFormat){case"first":D=this._symbol+A+D;
break;
case"after-sign":D=A+this._symbol+D;
break;
case"last":D=A+D+this._symbol;
break;
}return D;
};
Exhibit.Formatter._ItemFormatter.prototype.format=function(F,C,B){var D=this;
var G=this.formatText(F);
var A=SimileAjax.DOM.createElementFromString('<a href="'+Exhibit.Persistence.getItemLink(F)+"\" class='exhibit-item'>"+G+"</a>");
var E=function(I,H,J){Exhibit.UI.showItemInPopup(F,I,D._uiContext);
};
SimileAjax.WindowManager.registerEvent(A,"click",E,this._uiContext.getSetting("layer"));
C(A);
};
Exhibit.Formatter._ItemFormatter.prototype.formatText=function(B){var A=this._uiContext.getDatabase();
var C=null;
if(this._title==null){C=A.getObject(B,"label");
}else{C=this._title.evaluateSingleOnItem(B,A).value;
}if(C==null){C=B;
}return C;
};
Exhibit.Formatter._DateFormatter.prototype.format=function(C,B,A){B(document.createTextNode(this.formatText(C)));
};
Exhibit.Formatter._DateFormatter.prototype.formatText=function(E){var B=(E instanceof Date)?E:SimileAjax.DateTime.parseIso8601DateTime(E);
if(B==null){return E;
}B.setTime(B.getTime()+this._timeZoneOffset);
var F="";
var A=this._segments;
for(var C=0;
C<A.length;
C++){var D=A[C];
if(typeof D=="string"){F+=D;
}else{F+=D(B);
}}return F;
};


/* editing-lens.js */
Exhibit.EditingLens={};
var NO_EDITING=0;
var SIMPLE_EDITING=1;
var ADVANCED_EDITING=2;
Exhibit.EditingLens=function(E,F,B,C){var A=this;
this._rootNode=F;
var D=B.getDatabase();
this.backend=new Exhibit.EditingBackend();
this._getItemData=function(){var G={};
var J=D.getAllProperties();
var K=Exhibit.ViewPanel.getPropertyValuesPairs(E,J,D);
for(var H=0;
H<K.length;
H++){var L=K[H];
G[L.propertyID]=[];
for(var I=0;
I<L.values.length;
I++){G[L.propertyID].push(L.values[I]);
}}return G;
};
this._restore=function(){Exhibit.UI.removeChildren(A._rootNode);
F.style.marginBottom="0em";
F.style.marginTop="0em";
F.style.border="none";
C(A);
};
this._revert=function(){A._itemData=this._getItemData();
};
this._revert();
};
Exhibit.EditingLens._getAreEditing=function(A){if(!A.areEditing){A.areEditing={};
}return A.areEditing;
};
Exhibit.EditingLens.setEditing=function(D,C,A){var B=Exhibit.EditingLens._getAreEditing(A);
switch(C){case SIMPLE_EDITING:case ADVANCED_EDITING:B[D]=C;
break;
default:B[D]=NO_EDITING;
}};
Exhibit.EditingLens.getEditing=function(C,A){var B=Exhibit.EditingLens._getAreEditing(A);
return B[C];
};
Exhibit.EditingLens.create=function(E,F,B,C,D,A){if(A==undefined||A==null){Exhibit.EditingLens.setEditing(E,NO_EDITING,B);
}else{Exhibit.EditingLens.setEditing(E,A,B);
}return new Exhibit.EditingLens(E,F,B,D);
};
Exhibit.EditingLens.prototype._constructDefaultUI=function(C,A,H){var P=this;
var N=H.getDatabase();
if(this._commonProperties==null){this._commonProperties=N.getAllProperties();
}var I=this._commonProperties;
var K=N.getObject(C,"label");
var O={elmt:A,className:"exhibit-lens",children:[{tag:"div",className:"exhibit-lens-title",field:"titlebar",title:K,children:[K]},{tag:"div",className:"exhibit-lens-body",children:[{tag:"table",className:"exhibit-lens-properties",field:"propertiesTable"}]},{tag:"div",className:"exhibit-lens-title",title:K,children:[K]},]};
var G=SimileAjax.DOM.createDOMFromTemplate(O);
A.setAttribute("ex:itemID",C);
this._TBody=G.propertiesTable.tBodies[0];
var L=N.getAllProperties();
var B=Exhibit.ViewPanel.getPropertyValuesPairs(C,L,N);
for(var F=0;
F<B.length;
F++){var E=B[F];
var J=G.propertiesTable.insertRow(F);
J.className="exhibit-lens-property";
J.setAttribute("ex:propertyID",E.propertyID);
var D=J.insertCell(0);
D.className="exhibit-lens-property-name";
D.innerHTML=E.propertyLabel;
var M=J.insertCell(1);
M.className="exhibit-lens-property-values";
this._fillCell(E.propertyID,M,H);
}A.style.marginBottom="2em";
A.style.marginTop="0.5em";
A.style.border="solid";
A.style.borderWidth="1";
this._makeEditing(C,A,H,Exhibit.EditingLens.getEditing(C,H));
};
Exhibit.EditingLens.prototype._makeEditing=function(E,C,F,A){var Q=this;
var D=document.createElement("span");
D.className="exhibit-toolboxWidget-popup screen";
var M=Exhibit.UI.createTranslucentImage("images/edit-icon.png");
M.className="exhibit-toolboxWidget-button";
SimileAjax.WindowManager.registerEvent(M,"click",function(S,R,T){Q._convertLens(E,C,F,A==0?1:0);
});
D.style.marginTop=A==0?1:0;
D.style.marginRight=A==0?1:0;
D.appendChild(M);
var N=document.createElement("div");
N.style.textAlign="right";
if(A==ADVANCED_EDITING){N.style.borderBottom="solid";
N.style.borderWidth=1;
}else{N.style.border="none";
}var J=document.createElement("span");
J.className="item-edit-button";
J.innerHTML=A==0?"Edit":"Done";
J.title=A==0?"Open editing view.":"Save and return to normal view.";
SimileAjax.WindowManager.registerEvent(J,"click",function(S,R,T){Q._convertLens(E,C,F,A==0?1:0);
});
var B=document.createElement("span");
B.className="item-edit-button";
B.innerHTML=A==1?"Advanced":"Simple";
B.title=A==1?"Show advanced view.":"Show simple view.";
SimileAjax.WindowManager.registerEvent(B,"click",function(S,R,T){Q._convertLens(E,C,F,A==1?2:1);
});
if(A==ADVANCED_EDITING){var O=document.createElement("span");
O.className="item-edit-button";
O.innerHTML="Add value";
O.title="Add a value to a property.";
SimileAjax.WindowManager.registerEvent(O,"click",function(){Q._openAddTagMenu(O,E,F);
});
var I=document.createElement("span");
I.className="item-edit-button";
I.innerHTML="Remove value";
I.title="Remove a value from a property.";
SimileAjax.WindowManager.registerEvent(I,"click",function(){Q._openRemoveTagMenu(I,E,F);
});
var L=document.createElement("span");
L.className="item-edit-button";
L.innerHTML="Revert";
L.title="Return to the previous saved state.";
L.onclick=function(){Q._revert();
Exhibit.UI.removeChildren(Q._rootNode);
Q._constructEditingLens(E,Q._rootNode,F);
};
var H=document.createElement("span");
H.className="item-edit-button";
H.innerHTML="Save";
H.title="Save the item.";
H.onclick=function(){Q._saveFromEditingLens(E,Q._rootNode,F);
};
N.appendChild(O);
N.appendChild(I);
N.appendChild(L);
N.appendChild(H);
}if(A!=NO_EDITING){N.appendChild(B);
}N.appendChild(J);
var K=N;
for(var G=0;
G<C.childNodes.length;
G++){var P=C.childNodes[G];
C.replaceChild(K,P);
K=P;
}C.appendChild(K);
};
Exhibit.EditingLens.prototype._convertLens=function(C,D,B,A){if(Exhibit.EditingLens.getEditing(C,B)==A){return ;
}Exhibit.EditingLens.setEditing(C,A,B);
if(Exhibit.EditingLens.getEditing(C,B)==NO_EDITING){this._saveFromEditingLens(C,this._rootNode,B);
}Exhibit.UI.removeChildren(D);
if(A==SIMPLE_EDITING){Exhibit.Lens._constructDefaultValueList=Exhibit.EditingLens._constructDefaultValueList;
}else{Exhibit.Lens._constructDefaultValueList=Exhibit.Lens.original_constructDefaultValueList;
}if(A==ADVANCED_EDITING){this._constructDefaultUI(C,D,B);
}else{this._restore();
}};
Exhibit.EditingLens.prototype._constructEditingLens=function(B,C,A){this._constructDefaultUI(B,C,A);
};
Exhibit.EditingLens.prototype.addButtons=function(B,A,C){var L=this;
var I=document.createElement("span");
I.className="item-edit-buttons";
var J=document.createElement("span");
J.className="item-edit-button";
J.innerHTML="Add value";
SimileAjax.WindowManager.registerEvent(J,"click",function(){L._openAddTagMenu(J,B,C);
});
var F=document.createElement("span");
F.className="item-edit-button";
F.innerHTML="Remove value";
SimileAjax.WindowManager.registerEvent(F,"click",function(){L._openRemoveTagMenu(F,B,C);
});
var H=document.createElement("span");
H.className="item-edit-button";
H.innerHTML="Revert";
H.onclick=function(){L._revert();
Exhibit.UI.removeChildren(L._rootNode);
L._constructEditingLens(B,L._rootNode,C);
};
var E=document.createElement("span");
E.className="item-edit-button";
E.innerHTML="Save";
E.onclick=function(){L._saveFromEditingLens(B,L._rootNode,C);
};
I.appendChild(J);
I.appendChild(F);
I.appendChild(E);
I.appendChild(H);
var G=I;
for(var D=0;
D<A.childNodes.length;
D++){var K=A.childNodes[D];
A.replaceChild(G,K);
G=K;
}A.appendChild(G);
A.style.padding="5px";
};
Exhibit.EditingLens.prototype._getTBody=function(){var A=function(D){var E=null;
if(D.tagName&&D.tagName.toLowerCase()=="tbody"){return D;
}else{for(var C=0;
C<D.childNodes.length;
C++){var B=A(D.childNodes[C]);
if(B!=null){E=B;
}}}return E;
};
if(this._TBody==null){this._TBody=A(this._rootNode);
}return this._TBody;
};
Exhibit.EditingLens.prototype._saveFromEditingLens=function(E,F,B){var A=this;
this.sync();
var D={};
var C=this._getItemData();
D.perform=function(){B.getDatabase().reloadItem(E,A._itemData);
};
D.undo=function(){B.getDatabase().reloadItem(E,C);
};
D.label="Changed "+C["label"][0];
SimileAjax.History.addAction(D);
};
Exhibit.EditingLens.prototype._fillCell=function(F,B,E){var D=this;
var C=this._itemData[F];
var G=E.getDatabase().getProperty(F).getValueType();
if(G=="item"){for(var A=0;
A<C.length;
A++){if(A>0){B.appendChild(document.createTextNode(", "));
}B.appendChild(Exhibit.UI.makeEditItemSpan(C[A],null,E,B.parentNode._toCheck));
}}else{for(var A=0;
A<C.length;
A++){this._addRemovableValueSpan(B,F,A,E,C.length>1);
}this._addAppendButton(F,B,E);
}};
Exhibit.EditingLens.prototype._addComaSpan=function(D,A,B,C){};
Exhibit.EditingLens.prototype._addAppendButton=function(F,A,C){var B=this;
var D=Exhibit.UI.createTranslucentImage("images/append-icon2.png");
D.width=10;
D.height=10;
D.title="add new value";
SimileAjax.WindowManager.registerEvent(D,"click",function(H,G,I){B._addValue(F,C);
});
A.appendChild(D);
if(this._itemData[F].length>1){D.className="shown";
}else{D.className="not-shown";
var E=A.parentNode;
SimileAjax.WindowManager.registerEvent(E,"mouseover",function(){numChildren=A.childNodes.length;
A.childNodes[numChildren-1].className="shown";
A.childNodes[numChildren-2].className="shown";
A.childNodes[numChildren-3].className="shown";
});
SimileAjax.WindowManager.registerEvent(E,"mouseout",function(){numChildren=A.childNodes.length;
A.childNodes[numChildren-1].className="not-shown";
A.childNodes[numChildren-2].className="not-shown";
A.childNodes[numChildren-3].className="not-shown";
});
}A.appendChild(D);
};
Exhibit.EditingLens.prototype.sync=function(G){var E=this._getTBody();
for(var D=0;
D<E.rows.length;
D++){var F=E.rows[D];
if(G==undefined||G==null||Exhibit.getAttribute(F,"ex:propertyID")==G){var B=[];
var A=Exhibit.UI.findClassMembers("editable-exhibit-value",F);
for(var C=0;
C<A.length;
C++){B.push(A[C].value);
}this._itemData[Exhibit.getAttribute(F,"ex:propertyID")]=B;
var H=Exhibit.UI.findClassMembers("exhibit-item",F);
for(var C=0;
C<H.length;
C++){B.push(H[C].innerHTML);
}this._itemData[Exhibit.getAttribute(F,"ex:propertyID")]=B;
}}};
Exhibit.EditingLens.prototype._addValue=function(F,B){var D=this._getTBody();
var E=B.getDatabase();
for(var C=0;
C<D.rows.length;
C++){var G=E.getProperty(F).getValueType();
if(Exhibit.getAttribute(this._getTBody().rows[C],"ex:propertyID")==F){var A=this._getTBody().rows[C].cells[1];
this.sync(F);
this._itemData[F].push("");
Exhibit.UI.removeChildren(A);
this._fillCell(F,A,B);
}}};
Exhibit.EditingLens.prototype._removeValue=function(F,C,B){var G=this._getTBody();
var E=B.getDatabase();
for(var D=0;
D<G.rows.length;
D++){var H=E.getProperty(F).getValueType();
if(Exhibit.getAttribute(G.rows[D],"ex:propertyID")==F){var A=G.rows[D].cells[1];
this.sync(F);
this._itemData[F].splice(C,1);
Exhibit.UI.removeChildren(A);
this._fillCell(F,A,B);
}}};
Exhibit.EditingLens.prototype._openRemoveTagMenu=function(C,A,F){var M=this;
this.sync();
var E=Exhibit.createPopupMenu(C);
E.elmt.style.width="15em";
E.appendSectionHeading("Remove property value:");
var J=function(N){if(N.length>20){return N.substr(0,15)+"...";
}else{return N;
}};
var B=[];
var I=database.getAllProperties();
for(var G=0;
G<I.length;
G++){var L=I[G];
if(L!="uri"&&database.countDistinctObjects(A,L)>0){var K=database.getProperty(L);
B.push({propertyID:L,label:K!=null?K.getLabel():L});
}}var H=function(Q,O){if(database.getProperty(Q).getValueType()=="item"){return ;
}var P=E.appendSubMenu(O);
for(var N=0;
N<M._itemData[Q].length;
N++){P.appendMenuItem(J(M._itemData[Q][N]),null,(function(R){return function(){M._removeValue(Q,R,F);
};
})(N));
}};
for(var G=0;
G<B.length;
G++){var D=B[G];
H(D.propertyID,D.label);
}E.open();
};
Exhibit.EditingLens.prototype._openAddTagMenu=function(C,A,F){var M=this;
this.sync();
var K=F.getDatabase();
var E=Exhibit.createPopupMenu(C);
E.appendSectionHeading("Add property value to:");
var B=[];
var I=K.getAllProperties();
for(var G=0;
G<I.length;
G++){var L=I[G];
if(L!="uri"&&K.countDistinctObjects(A,L)>0){var J=K.getProperty(L);
B.push({propertyID:L,label:J!=null?J.getLabel():L});
}}var H=function(P,O){var N=E.makeMenuItem(O,null,function(){M._addValue(P,F);
});
E.elmt.appendChild(N);
};
for(var G=0;
G<B.length;
G++){var D=B[G];
H(D.propertyID,D.label);
}E.open();
};
Exhibit.EditingLens.prototype._addRemovableValueSpan=function(C,I,D,E,F){var J=this;
var H=this._itemData[I][D];
var G=document.createElement("input");
G.className="editable-exhibit-value";
G.value=H;
C.appendChild(G);
var A=Exhibit.UI.createTranslucentImage("images/remove-icon.png");
A.style.cursor="pointer";
A.width=10;
A.height=10;
A.style.margin=0;
A.title="remove value";
SimileAjax.WindowManager.registerEvent(A,"click",function(L,K,M){J._removeValue(I,D,E);
});
C.appendChild(A);
var B=document.createElement("span");
B.appendChild(document.createTextNode(", "));
C.appendChild(B);
if(F){A.className="shown";
B.className="shown";
}else{A.className="not-shown";
B.className="not-shown";
}};
Exhibit.EditingLens.prototype._constructFromLensTemplateURL=function(B,D,A,C){Exhibit.Lens.lastItemID=B;
Exhibit.Lens.prototype._constructFromLensTemplateURL(B,D,A,C);
this._makeEditing(B,D,A,Exhibit.EditingLens.getEditing(B,A));
};
Exhibit.EditingLens.prototype._constructFromLensTemplateDOM=function(C,D,A,B){Exhibit.Lens.lastItemID=C;
Exhibit.Lens.prototype._constructFromLensTemplateDOM(C,D,A,B);
this._makeEditing(C,D,A,Exhibit.EditingLens.getEditing(C,A));
};
Exhibit.EditingLens._constructDefaultValueList=function(B,F,E,A,D,C){A.formatList(B,B.size(),F,function(G){E.appendChild(G);
},true);
E.className="editable-exhibit-value";
SimileAjax.WindowManager.registerEvent(E,"click",function(){if(E.className!="editing-parent"){Exhibit.UI.removeChildren(E);
E.className="editing-parent";
B.visit(function(G){Exhibit.EditingLens._addInput(B,G,F,E,A,D,C);
});
Exhibit.EditingLens._addAppendIcon(B,F,E,A,D,C);
Exhibit.EditingLens._addSaveAndCancelButtons(E,A,D,C,B,F);
}});
};
Exhibit.EditingLens._addInput=function(H,G,C,D,E,A,I){var F=document.createElement("input");
F.className="editable-exhibit-value";
F.value=G;
D.appendChild(F);
Exhibit.EditingLens._addRemoveIcon(H,C,D,E,A,I,G);
var B=document.createElement("span");
B.appendChild(document.createTextNode(", "));
D.appendChild(B);
};
Exhibit.EditingLens._addRemoveIcon=function(C,H,G,B,F,E,D){var A=Exhibit.UI.createTranslucentImage("images/remove-icon.png");
A.width=10;
A.height=10;
A.style.margin=0;
A.title="remove value";
G.onclick="";
G.onclick=null;
SimileAjax.WindowManager.registerEvent(A,"click",function(J,I,K){C.remove(D);
Exhibit.UI.removeChildren(G);
Exhibit.EditingLens._constructDefaultValueList(C,H,G,B,F,E);
});
G.appendChild(A);
};
Exhibit.EditingLens._addAppendIcon=function(B,G,F,A,E,D){var C=Exhibit.UI.createTranslucentImage("images/append-icon2.png");
C.width=10;
C.height=10;
C.title="add new value";
SimileAjax.WindowManager.registerEvent(C,"click",function(I,H,J){B.add("");
Exhibit.UI.removeChildren(F);
Exhibit.EditingLens._constructDefaultValueList(B,G,F,A,E,D);
});
F.appendChild(C);
};
Exhibit.EditingLens.makeButton=function(A,C){var B=document.createElement("span");
B.className="item-edit-button";
B.innerHTML=A;
SimileAjax.WindowManager.registerEvent(B,"click",C);
return B;
};
Exhibit.EditingLens._addSaveAndCancelButtons=function(A,F,B,J,I,E){var H=function(){var L=Exhibit.UI.findClassMembers("editable-exhibit-value",A);
var M=[];
for(var N=0;
N<L.length;
N++){M.push(L[N].value);
}itemEntry={};
itemEntry[J]=M;
itemEntry["id"]=B;
F.getDatabase().reloadItem(B,itemEntry);
};
var K=function(){Exhibit.UI.removeChildren(A);
Exhibit.EditingLens._constructDefaultValueList(I,E,A,F,B,J);
};
var D=function(){H();
K();
};
var G=Exhibit.EditingLens.makeButton("Save",D);
var C=Exhibit.EditingLens.makeButton("Cancel",K);
A.appendChild(G);
A.appendChild(C);
};
Exhibit.UIContext.prototype.format=function(D,E,B,A){var C;
if(E in this._formatters){C=this._formatters[E];
}else{C=this._formatters[E]=new Exhibit.Formatter._constructors[E](this);
}C.format(D,B,A);
};
Exhibit.UIContext.prototype.formatList=function(C,D,E,B,A){if(this._listFormatter==null){this._listFormatter=new Exhibit.Formatter._ListFormatter(this);
}this._listFormatter.formatList(C,D,E,B,A);
};


/* lens.js */
Exhibit.LensRegistry.prototype.createLens=function(B,A,D,C){var H=this.getLens(B,D);
var E=function(J){if(H==null){J._constructDefaultUI(B,A,D);
}else{if(typeof H=="string"){J._constructFromLensTemplateURL(B,A,D,H);
}else{J._constructFromLensTemplateDOM(B,A,D,H);
}}};
var F={};
try{if(C){F=Exhibit.EditingLens.create(B,A,D,F,E);
}else{F=new Exhibit.Lens();
}}catch(G){SimileAjax.Debug.warn("Something wrong happened while building the editing lens, reverting to regular lens.");
F=new Exhibit.Lens();
}E(F);
if(C){var I=function(K,J){if(Exhibit.getAttribute(K,"ex:content")!=null){Exhibit.setAttribute(J,"ex:content",Exhibit.getAttributes(K,"ex:content"));
}else{for(var L=0;
L<K.childNodes.length;
L++){I(K.childNodes[L],J.childNodes[L]);
}}};
}return F;
};
Exhibit.Lens._constructFromLensTemplateNode=function(I,M,b,D,K,J){if(typeof b=="string"){D.appendChild(document.createTextNode(b));
return ;
}var P=K.getDatabase();
var G=b.children;
if(b.condition!=null){if(b.condition.test=="if-exists"){if(!b.condition.expression.testExists(I,M,"value",P)){return ;
}}else{if(b.condition.test=="if"){if(b.condition.expression.evaluate(I,M,"value",P).values.contains(true)){if(G!=null&&G.length>0){Exhibit.Lens._constructFromLensTemplateNode(I,M,G[0],D,K,J);
}}else{if(G!=null&&G.length>1){Exhibit.Lens._constructFromLensTemplateNode(I,M,G[1],D,K,J);
}}return ;
}else{if(b.condition.test=="select"){var C=b.condition.expression.evaluate(I,M,"value",P).values;
if(G!=null){var E=null;
for(var W=0;
W<G.length;
W++){var N=G[W];
if(N.condition!=null&&N.condition.test=="case"){if(C.contains(N.condition.value)){Exhibit.Lens._constructFromLensTemplateNode(I,M,N,D,K,J);
return ;
}}else{if(typeof N!="string"){E=N;
}}}}if(E!=null){Exhibit.Lens._constructFromLensTemplateNode(I,M,E,D,K,J);
}return ;
}}}}var L=Exhibit.Lens._constructElmtWithAttributes(b,D,P);
if(b.contentAttributes!=null){var X=b.contentAttributes;
for(var U=0;
U<X.length;
U++){var O=X[U];
var C=[];
O.expression.evaluate(I,M,"value",P).values.visit(function(a){C.push(a);
});
L.setAttribute(O.name,C.join(";"));
}}if(b.subcontentAttributes!=null){var F=b.subcontentAttributes;
for(var U=0;
U<F.length;
U++){var O=F[U];
var d=O.fragments;
var S="";
for(var Q=0;
Q<d.length;
Q++){var A=d[Q];
if(typeof A=="string"){S+=A;
}else{S+=A.evaluateSingle(I,M,"value",P).value;
}}L.setAttribute(O.name,S);
}}var R=b.handlers;
for(var V=0;
V<R.length;
V++){var B=R[V];
L[B.name]=B.code;
}if(b.control!=null){switch(b.control){case"item-link":var Y=document.createElement("a");
Y.innerHTML=Exhibit.l10n.itemLinkLabel;
Y.href=Exhibit.Persistence.getItemLink(I["value"]);
Y.target="_blank";
L.appendChild(Y);
}}else{if(b.content!=null){var S=b.content.evaluate(I,M,"value",P);
if(G!=null){var T={"value":S.valueType,"index":"number"};
var H=1;
var Z=function(c){var a={"value":c,"index":H++};
for(var e=0;
e<G.length;
e++){Exhibit.Lens._constructFromLensTemplateNode(a,T,G[e],L,K,J);
}};
if(S.values instanceof Array){for(var U=0;
U<S.values.length;
U++){Z(S.values[U]);
}}else{S.values.visit(Z);
}}else{Exhibit.Lens._constructDefaultValueList(S.values,S.valueType,L,K,J.itemID,b.content._rootNode._segments[0].property);
}}else{if(G!=null){for(var U=0;
U<G.length;
U++){Exhibit.Lens._constructFromLensTemplateNode(I,M,G[U],L,K,J);
}}}}};
Exhibit.Lens.original_constructDefaultValueList=Exhibit.Lens._constructDefaultValueList;
